package net.oschina.arvin.admin.model.vo;

import net.oschina.arvin.admin.model.Privilege;

import java.util.List;

/**
 * 权限
 *
 * @author Arvin
 * @time 2017/11/25 22:00
 */
public class PrivilegeVO {

    /** 主键ID */
    private Long id;

    /** 名称 */
    private String name;

    /** 权限代码 */
    private String code;

    /** 是否在菜单栏展示 */
    private boolean showMenu;

    /** 主地址，即点开后请求的地址 */
    private String mainUrl;

    /** 上级权限ID */
    private PrivilegeVO parent;

    /** 子级权限 */
    private List<PrivilegeVO> children;

    public PrivilegeVO() {
    }

    public PrivilegeVO(Privilege privilege) {
        this.id = privilege.getId();
        this.name = privilege.getName();
        this.code = privilege.getCode();
        this.showMenu = privilege.getShowMenu() != null && privilege.getShowMenu() == 1;
        this.mainUrl = privilege.getMainUrl();
        if (privilege.getParentId() != null && privilege.getParentId() > 0) {
            PrivilegeVO parent = new PrivilegeVO();
            parent.setId(privilege.getId());
            this.parent = parent;
        }
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public boolean isShowMenu() {
        return showMenu;
    }

    public void setShowMenu(boolean showMenu) {
        this.showMenu = showMenu;
    }

    public String getMainUrl() {
        return mainUrl;
    }

    public void setMainUrl(String mainUrl) {
        this.mainUrl = mainUrl;
    }

    public PrivilegeVO getParent() {
        return parent;
    }

    public void setParent(PrivilegeVO parent) {
        this.parent = parent;
    }

    public List<PrivilegeVO> getChildren() {
        return children;
    }

    public void setChildren(List<PrivilegeVO> children) {
        this.children = children;
    }
}
